//
//  StatusRetweetedCell.m
//  weibo110
//
//  Created by 臧松 on 16/1/7.
//  Copyright © 2016年 臧松. All rights reserved.
//
#define StatusCellMargin 12

#import "StatusRetweetedCell.h"
#import "UILabel+Extension.h"
#import "Masonry.h"
@interface StatusRetweetedCell ()

@property (nonatomic,strong) UIButton * backButton;

@property (nonatomic,strong) UILabel * retweetedLabel;

@end

@implementation StatusRetweetedCell
// 懒加载控件
-(UIButton *)backButton{
    if (_backButton == nil) {
        _backButton = [[UIButton alloc]init];
        _backButton.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.0];
    }
    return _backButton;
}
-(UILabel *)retweetedLabel{
    if (_retweetedLabel == nil) {
        _retweetedLabel = [UILabel labelWithTitle:@"转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博" fontSize:14 color:[UIColor darkGrayColor] screenInset:StatusCellMargin];
    }
    return _retweetedLabel;
}
-(void)setStatusViewModel:(StatusViewModel *)statusViewModel{
    
    [super setStatusViewModel:statusViewModel];
    self.retweetedLabel.text = statusViewModel.retweetedText;
    [self.pictureView mas_updateConstraints:^(MASConstraintMaker *make) {
        float offSet = 0.f;
        if (statusViewModel.thumbnailUrls.count > 0) {
            offSet = StatusCellMargin;
        }else{
            offSet = 0.f;
        }
        make.top.equalTo(self.retweetedLabel.mas_bottom);
    }];

}
-(void)setupUI{
    [super setupUI];
    // 添加控件
    [self.contentView insertSubview:self.backButton belowSubview:self.pictureView];
    [self.contentView insertSubview:self.retweetedLabel aboveSubview:self.backButton];
    
    // 自动布局
    [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentLabel.mas_bottom);
        make.left.equalTo(self.contentView.mas_left);
        make.right.equalTo(self.contentView.mas_right);
        make.bottom.equalTo(self.bottomView.mas_top);
    }];
    
    [self.retweetedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.backButton.mas_top).offset(StatusCellMargin);
        make.left.equalTo(self.backButton.mas_left).offset(StatusCellMargin);
    }];
    [self.pictureView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.retweetedLabel.mas_bottom).offset(StatusCellMargin);
        make.left.equalTo(self.retweetedLabel.mas_left);
        make.height.equalTo(@90);
        make.width.equalTo(@300);
    }];

}
@end
